package cn.codenest.springboot.mongo.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import java.io.Serializable;
import java.util.List;

/**
 * @ClassName: ItemGroupEntity
 * @author: Zhihui.Liu
 * @date: 2021/11/04 16:28
 * @Description:
 */
@Data
public class ItemGroupEntity implements Serializable {

    public static final String COLLECTION_NAME = "itemGroup";

    @Id
    private String id;

    private String name;

    private String description;

    private Long createTime;

    private Long updateTime;

    private List<UserEntity> users;

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (obj instanceof ItemGroupEntity) {
            ItemGroupEntity other = (ItemGroupEntity) obj;
            //需要比较的字段相等，则这两个对象相等
            if (this.id.equals(other.id) &&
                    this.name.equals(other.name)) {
                return true;
            }
        }
        return false;
    }


    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + (id == null ? 0 : id.hashCode());
        result = 31 * result + (name == null ? 0 : name.hashCode());
        return result;
    }


}
